/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo
 * All rights reserved.
 */
package ac.jp.u_tokyo.SyncLib.language;


public abstract class EvaluationFailedException extends Exception{

	/**
	 * 
	 */
	private static final long serialVersionUID = 0L;
	private int _line;
	
	public EvaluationFailedException(int line)
	{
		super();
		_line = line;
	}

	@Override
	public String getMessage()
	{
		return "line " + _line + ": " + getInternalMessage();
	}

	protected abstract String getInternalMessage();
	
}

class ParameterNotAssigned extends EvaluationFailedException
{
	private String _paraName;

	/**
	 * 
	 */
	private static final long serialVersionUID = 0L;

	@Override
	protected String getInternalMessage()
	{
		return "No value is provied to non-default parameter \'" + _paraName + "\'.";
	}

	public ParameterNotAssigned(int line, String paraName)
	{
		super(line);
		_paraName = paraName;
	}
	
}

class ParameterNumberNotMatchException extends EvaluationFailedException {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2629677913849602891L;
	private int _paraCount;

	@Override
	protected String getInternalMessage()
	{
		return "The synchronizer takes " + _paraCount + " parameters.";
	}

	public ParameterNumberNotMatchException(int line, int paraCount)
	{
		super(line);
		_paraCount = paraCount;
	}
	
}

class ParameterNumberNotEqualException extends EvaluationFailedException {
	/**
	 * 
	 */
	private static final long serialVersionUID = 0L;
	/**
	 * 
	 */
	private int _defaultCount;
	private int _paraCount;

	@Override
	protected String getInternalMessage()
	{
		return String.format("The synchronizer takes %1$d argument which is different from the default %2$d arguement.", _paraCount, _defaultCount);
	}

	public ParameterNumberNotEqualException(int line, int paraCount, int defaultCount)
	{
		super(line);
		_paraCount = paraCount;
		_defaultCount = defaultCount;
	}
	
}

class ReferenceNotFoundException extends EvaluationFailedException 
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5264053924181821510L;
	
	private String _refName;

	public ReferenceNotFoundException(int line, String refName)
	{
		super(line);
		_refName = refName;
	}

	@Override
	protected String getInternalMessage()
	{
		return "\'" + _refName + "\' not founded";
	}

	
	
	
}
